﻿using DevExpress.XtraEditors;
using MDIDemo.Model;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace DevMy.PublicSetUp
{
    public class Class_LookUpEdit
    {
        /// <summary>
        /// 
        /// </summary>
        /// <param name="lookUpEdit">本尊</param>
        /// <param name="DisplayField">显示字段</param>
        /// <param name="ValueField">值字段</param>
        /// <param name="lookUpEditColumnModels">列信息</param>
        public void SetLookUpEdit(LookUpEdit lookUpEdit, string DisplayField, string ValueField
            , LookUpEditColumnModel[] lookUpEditColumnModels
            ,string NullText)
        {
            lookUpEdit.Properties.NullText = string.Format("请选择{0}", NullText);
            lookUpEdit.Properties.Appearance.Font = new System.Drawing.Font("Tahoma", 10.5F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(0)));
            lookUpEdit.Properties.Appearance.Options.UseFont = true;
            lookUpEdit.Properties.DisplayMember = DisplayField;
            lookUpEdit.Properties.ValueMember = ValueField;
            lookUpEdit.Properties.Columns.Clear();
            if (lookUpEditColumnModels != null)
            {
                for (int i = 0; i < lookUpEditColumnModels.Length; i++)
                {
                    lookUpEdit.Properties.Columns.Add(new DevExpress.XtraEditors.Controls.LookUpColumnInfo(
                            lookUpEditColumnModels[i].FieldName, lookUpEditColumnModels[i].Caption));
                }
            }
        }
    }
}
